<template>
  <div>
    <van-nav-bar
      :title="nTitle"
      left-text="返回"
      left-arrow
      @click-left="goBack"
      placeholder
    />
    <div class="dl-background"></div>
    <div class="dl-content">
      <div class="dl-box">
        <!-- 内容插槽 -->
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "DefLayout",

  props: {
    // 导航栏标题
    nTitle: {
      type: String,
      default: "nTitle未定义",
    },
    // 导航栏返回状态(默认返回我的页面)
    isGoBack: {
      type: Boolean,
      default: false,
    },
  },

  methods: {
    // 导航栏返回
    goBack() {
      // 判断导航栏返回状态(默认返回我的页面)
      if (this.isGoBack) {
        // 为真则返回上一级
        this.$router.go(-1);
      } else {
        // 为假则返回我的页面
        this.$router.replace({ name: "User" });
      }
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.van-icon {
  color: #ffa341;
}
/deep/.van-nav-bar__text {
  color: #ffa341;
}
/deep/.van-nav-bar__title {
  color: #333;
}

.dl-background {
  width: 100%;
  height: 100px;
  background-color: #ff594d;
}
.dl-content {
  margin-top: -30px;
  padding: 10px;
  color: #666;
  font-size: 14px;
  box-sizing: border-box;
  .dl-box {
    // min-height: calc(100vh - 140px);
    // padding: 10px;
    background-color: #fff;
    // border-radius: 10px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-sizing: border-box;
  }
}
</style>